package com.itheima.dao;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

public interface UserMapper {

    @Select("")
    public User findByUsernameAndPassword(String username, String password);
    @Select("select * from sys_user")
    public List<User> findAll();
    @Insert("insert into sys_user values(#{id},#{username},#{password},#{email},#{telephone},#{registertime},#{photo},#{statu})")
    @Options(useGeneratedKeys=true, keyProperty="id", keyColumn="id")
    public Long insert(User user);
    @Insert("insert into sys_user_role values(#{userId},#{roleId})")
    public void saveUserRoleRel(@Param("userId") Long userId, @Param("roleId") Long roleId);
    @Delete("delete from sys_user where id=#{id}")
    public void delete(Long userId);
    @Delete("delete from sys_user_role where userId=#{userId}")
    public void deleteUserRoleRel(Long userId);
    @Select("select * from sys_user where id=#{id}")
    public User findById(Long id);
}
